package org.angelica.core.wrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 响应数据包装类
 * @author aizhimin
 */
public class ResponseWrapper {

    /**
     * 包装分页查询返回数据
     * @param ipage
     * @return
     */
    public static Map<String,Object> wrapperPage(IPage<?> ipage){
        Map<String,Object> dataMap = Maps.newLinkedHashMap();
        dataMap.put("list",ipage.getRecords());
        dataMap.put("pagination",Pagination.builder()
                .total(ipage.getTotal())
                .pageSize(ipage.getSize())
                .current(ipage.getCurrent()).build());
        return dataMap;
    }

}
